//
//  SpotLookBillView.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/7/2.
//

import UIKit

class SpotLookBillView: UIView,UITableViewDelegate,UITableViewDataSource {
    var orderInfoModel:OrderListModel!
    var collectionLab:UILabel!
    var deliveryLab:UILabel!

    func setOrderInfoModel(orderInfoModel:OrderListModel) {
        self.orderInfoModel = orderInfoModel
    }
   
    @objc func clickCancelBtn() {
        self.removeFromSuperview()
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:UITableViewCell = UITableViewCell.init()
        return cell;
    }
    
    lazy var mainView: UIView = {
        let mainView = UIView()
        mainView.backgroundColor = UIColor.white
        mainView.layer.masksToBounds = true
        mainView.layer.cornerRadius = 15
        return mainView
    }()
    
    lazy var cencelBtn: UIButton = {
        let cencelBtn = UIButton.init(type: .custom)
        cencelBtn.setImage(UIImage.init(named: "login_cancel"), for: .normal)
        cencelBtn.addTarget(self, action: #selector(clickCancelBtn), for: .touchUpInside)
        return cencelBtn
    }()
    
    lazy var tableview: UITableView = {
        let tableview = UITableView()
        tableview.delegate = self
        tableview.dataSource = self
        tableview.backgroundColor = UIColor.white
        tableview.separatorStyle = UITableViewCell.SeparatorStyle.none
        tableview.register(UINib.init(nibName: "SpotLookBillCell", bundle: nil), forCellReuseIdentifier: "cell")
        tableview.keyboardDismissMode = UIScrollView.KeyboardDismissMode.onDrag
        return tableview
    }()
    lazy var tableFootView: UIView = {
        var deliveryLabHeight:CGFloat = 100
        if orderInfoModel.payType != 2 {
            deliveryLabHeight = 100 - 58;
        }
        let tableFootView = UIView.init(frame: CGRect.init(x: 0, y: 0, width: Constants.screenWidth, height: deliveryLabHeight))
        let view = UIView.init(frame: CGRect.init(x: 20, y: 0, width: Constants.screenWidth - 20, height: 1))
        view.backgroundColor = UIColor.init(hexString: "#CACACA")
        let label1 = UILabel.init(frame: CGRect.init(x: 15, y: 18, width: Constants.screenWidth - 130, height: 20))
        label1.font = UIFont.systemFont(ofSize: 14)
        label1.textColor = UIColor.init(hexString: "#000000")
        label1.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_collectionDelivery)
        collectionLab = UILabel.init(frame: CGRect.init(x: Constants.screenWidth - 125, y: 18, width: 110, height: 20))
        collectionLab.font = UIFont.systemFont(ofSize: 14)
        collectionLab.textColor = UIColor.init(hexString: "#0F0F0F")
        collectionLab.textAlignment = .right
        if orderInfoModel.payType == 2 {
            let label3 = UILabel.init(frame: CGRect.init(x: 15, y: 53, width: Constants.screenWidth - 170, height: 20))
            label3.font = UIFont.systemFont(ofSize: 18)
            label3.textColor = UIColor.init(hexString: "#0F0F0F")
            label3.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.WL_spot_deliveryDeduction)
            label3.numberOfLines = 0
            
            deliveryLab = UILabel.init(frame: CGRect.init(x: Constants.screenWidth - 145, y: 53, width: 130, height: 20))
            deliveryLab.font = UIFont.systemFont(ofSize: 18)
            deliveryLab.textColor = UIColor.init(hexString: "#B20000")
            deliveryLab.textAlignment = .right
            tableFootView.addSubview(label3)
            tableFootView.addSubview(deliveryLab)
        }
        tableFootView.addSubview(label1)
        tableFootView.addSubview(collectionLab)
        tableFootView.addSubview(view)
        return tableFootView
    }()
    
    lazy var titleLab: UILabel = {
        let titleLab = UILabel.init()
        titleLab.font = UIFont.boldSystemFont(ofSize: 17)
        titleLab.textColor = UIColor.init(hexString: "#4C4C4C")
        return titleLab
    }()

}
